package com.buddy.qreport.template.tpls.table.basic;

import com.buddy.qreport.template.ReportDataDimension;
import com.buddy.qreport.template.IReportTemplate;
import com.buddy.qreport.template.annotation.ReportTemplate;
import com.buddy.qreport.template.tpls.ReportDisplayType;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

@ReportTemplate(type = IReportTemplate.TYPE_NAME_TABLE)
public class BasicTableIReportTemplate implements IReportTemplate {

    private String demoJs;

    private String optionJs;

    private List<ReportDataDimension> dataDimensions;

    public BasicTableIReportTemplate() {

        this.dataDimensions = Collections.singletonList(new ReportDataDimension("数据","data",true));

        demoJs =  new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("template/table/basic/demo.js")))
                .lines().parallel().collect(Collectors.joining("\n"));


        optionJs =  new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("template/table/basic/template.js")))
                .lines().parallel().collect(Collectors.joining("\n"));
    }

    @Override
    public ReportDisplayType getDisplayType() {
        return ReportDisplayType.TABLE;
    }

    @Override
    public String getDescription() {
        return "基础数据表格";
    }

    @Override
    public String getDemoJs() {
        return demoJs;
    }

    @Override
    public String getTemplateOptionJs() {
        return optionJs;
    }

    @Override
    public String getName() {
        return "basic_table";
    }

    @Override
    public List<ReportDataDimension> getDataDimensions() {


        return dataDimensions;
    }




}
